package com.xs.ahoi.hcxs.tencent;

import android.content.ComponentName;
import android.content.Intent;
import com.xs.ahoi.hcxs.utils.FileUtil;

/**
 * author: ahoi
 * date: 2018/8/16 13:44
 * description: 微信登录 分享功能
 */
public class WXManager {

    // 分享文件
    public static Intent shareFile(String filePath) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        ComponentName component = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
        intent.setComponent(component);
        intent.putExtra(Intent.EXTRA_STREAM, FileUtil.getFileUri(filePath));
        intent.setType("text/plain");
        return Intent.createChooser(intent, "share to...");
    }

    // 分享文本
    public static Intent shareText(String text) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        // 分享精确到微信的页面，朋友圈页面，或者选择好友分享页面
        ComponentName component = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
        intent.setComponent(component);
        intent.putExtra(Intent.EXTRA_TEXT, text);
        intent.setType("text/plain");
        return Intent.createChooser(intent, "share to...");
    }

}
